<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.grep.extra.dao.impl.TaskDAOSQL,java.util.*,com.grep.extra.factory.data.impl.TaskUrl,com.grep.web.manager.FenYe"%>
<%
	response.setCharacterEncoding("utf-8");
	String index = request.getParameter("index");
	String pagenum = request.getParameter("pagenum");
	String taskid = request.getParameter("taskid");

	TaskDAOSQL taskdao = new TaskDAOSQL();

	int suoyin = Integer.parseInt(index);
	int pagesize = Integer.parseInt(pagenum);

	//得到任务URL数量
	int count = taskdao.getTaskUrlCountbyTaskId(taskid);
	
	FenYe fenye = new FenYe();
	List<TaskUrl> listtaskurl = new ArrayList<TaskUrl>();
	
	listtaskurl = fenye.getTaskUrlFenYeData(taskid, suoyin,pagesize);
	
	//listtaskurl = taskdao.getTaskUrlsByTaskId(taskid, suoyin, pagesize);

	String responseText = "[";
	for (int i = 0; i < listtaskurl.size(); i++) {

		TaskUrl task = new TaskUrl();
		task = listtaskurl.get(i);
		String urlid = task.getId();
		String taskurl = task.getTaskUrl();
		if (i == listtaskurl.size() - 1) {
			responseText += "{\"urlid\": \"" + urlid+"\",\"taskurl\":\"" + taskurl + "\",\"count\": \""+count+"\"}";
		} else {
			responseText += "{\"urlid\": \"" + urlid+"\",\"taskurl\":\"" + taskurl + "\"},";
		}
	}

	responseText += "]";
	response.getWriter().println(responseText);
%>